package main

import (
	"encoding/json"
	"fmt"
	"io/ioutil"
	"net/http"
)

func main() {

	type good struct {
		Count, Name, Price, id, tid, img string
	}

	type order struct {
		Id, Imei, shop_name, consignee_name, consignee_mobile, consignee_address, time, order_sn, long, shop_phone string
		Menu                                                                                                       []good
	}

	str := "http://localhost/go/mysql.test.php?imei=355839022517280"
	resp, err := http.Get(str) //使用get方法访问
	if err != nil {
		return
	}
	input, err1 := ioutil.ReadAll(resp.Body) //读取流数据
	if err1 != nil {
		return
	}
	fmt.Println(input)
	var jj order
	err2 := json.Unmarshal(input[6:], &jj) //解析json数据
	if err2 != nil {
		fmt.Println("Can't decode json message", err2)
	}

	fmt.Println(jj.Menu)
	for _, mm := range jj.Menu {
		fmt.Println(mm.Count, mm.Name)
	}
	//fmt.Println(string(input))

	//fmt.Println("+++++++++++++++++++++++++++++++++")

	//var j2 order
	//ii := `{"id":"0"}`
	//err3 := json.Unmarshal([]byte(ii), &j2) //解析json数据
	//if err3 != nil {
	//	fmt.Println("Can't decode json message", err3)
	//}
	//fmt.Println(j2.Id)

	////var bb bool = (input == []byte(ii))
	//fmt.Println("----------------")
	//fmt.Println([]byte("{"))
	//fmt.Println(input)
	//fmt.Println(aa)
	//fmt.Println([]byte(ii))
	//fmt.Println(ii)
	//fmt.Println("=======================")
	//var cc byte = 123
	//ind := bytes.IndexByte(input, cc)
	//ll := len(input)
	//fmt.Println(ind, ll)
	//fmt.Println(string(input[ind:]))

}

/*
输出结果

[{1 酸菜肉丝面 12.00   }]
1 酸菜肉丝面
*/
